<?php
add_action('init', 'db_hotel_price');
function db_hotel_price()
{	
	global $wpdb;
	$hotel_price 		= $wpdb->prefix . "hotel_price";
			
	if ($wpdb->get_var("SHOW TABLES LIKE '$hotel_price'") != $hotel_price)
	{
		$wpdb->query("CREATE TABLE {$hotel_price}
		(			
			ID  mediumint(10) AUTO_INCREMENT PRIMARY KEY ,
			typeroom 			VARCHAR(50)  NULL,
			max			 		VARCHAR(50)  NULL,
			totalofroom	 		INT  NULL,
			roomempty	 		INT  NULL,
			ratefornight 		VARCHAR(50)  NULL,
			hotelID				INT NOT NULL			
		)ENGINE=MyISAM DEFAULT CHARSET=utf8");
	}
	
	/*****************************************************/
	$tour_price 		= $wpdb->prefix . "tour_price";
			
	if ($wpdb->get_var("SHOW TABLES LIKE '$tour_price'") != $tour_price)
	{
		$wpdb->query("CREATE TABLE {$tour_price}
		(			
			ID  mediumint(10) AUTO_INCREMENT PRIMARY KEY ,
			travelinparty 		VARCHAR(50)  NULL,
			standard	 		INT  NULL,
			superior	 		INT  NULL,
			firstclass	 		INT  NULL,
			deluxe		 		INT  NULL,
			tourID				INT NOT NULL			
		)ENGINE=MyISAM DEFAULT CHARSET=utf8");
	}
	
/*****************************************************/
	$passport 		= $wpdb->prefix . "passports";
			
	if ($wpdb->get_var("SHOW TABLES LIKE '$passport'") != $passport)
	{
		$wpdb->query("CREATE TABLE {$passport}
		(			
			ID  mediumint(10) AUTO_INCREMENT PRIMARY KEY ,
			customerID	 		INT  NULL,
			passportNumber 		VARCHAR(50)  NULL,
			expiration	 		DATETIME NULL,						
			date				DATETIME NULL			
		)ENGINE=MyISAM DEFAULT CHARSET=utf8");
	}
	
/*****************************************************/
	$mytickets 		= $wpdb->prefix . "tickets";
			
	if ($wpdb->get_var("SHOW TABLES LIKE '$mytickets'") != $mytickets)
	{
		$wpdb->query("CREATE TABLE {$mytickets}
		(			
			ID  mediumint(10) AUTO_INCREMENT PRIMARY KEY ,
			transport 		VARCHAR(50)  NULL,
			goway	 		VARCHAR(50)  NULL,
			gofrom	 		VARCHAR(150)  NULL,
			goto 			VARCHAR(150)  NULL,
			checkIn		 	DATETIME NOT NULL,
			timeIn			VARCHAR(50)  NULL,
			checkOut		DATETIME NOT NULL,
			timeOut			VARCHAR(50)  NULL,
			adults			VARCHAR(50)  NULL,
			childrent		VARCHAR(50)  NULL,
			infant			VARCHAR(50)  NULL,
			onday			VARCHAR(150)  NULL,
			status			VARCHAR(150)  NULL,
			paymentID		INT NULL,
			customerID		INT NOT NULL,
			state			VARCHAR(50)  NULL,
			date			DATETIME NOT NULL
		)ENGINE=MyISAM DEFAULT CHARSET=utf8");
	}
	
	/*****************************************************/
	$customers 		= $wpdb->prefix . "customers";
			
	if ($wpdb->get_var("SHOW TABLES LIKE '$customers'") != $customers)
	{
		$wpdb->query("CREATE TABLE {$customers}
		(			
			ID  mediumint(10) AUTO_INCREMENT PRIMARY KEY ,
			customerName 			VARCHAR(150) NOT NULL,
			customerEmail 			VARCHAR(150) NOT NULL,
			customerAddress 		VARCHAR(150) NOT NULL,
			customerPhone 			VARCHAR(150) NOT NULL,
			customerFax 			VARCHAR(150) NOT NULL,
			customerComment			VARCHAR(250) NOT NULL,
			guestParent				INT NULL,
			date		 			DATETIME NOT NULL			
		)ENGINE=MyISAM DEFAULT CHARSET=utf8");
	}
	
	/*****************************************************/
	$order 		= $wpdb->prefix . "orders";
	if ($wpdb->get_var("SHOW TABLES LIKE '$order'") != $order)
	{
		$wpdb->query("CREATE TABLE {$order}
		(			
			ID  			mediumint(10) AUTO_INCREMENT PRIMARY KEY ,
			customerID 			INT NOT NULL,			
			itemID			 	INT NOT NULL,			
			paymentID			INT NULL,
			orderStatus			VARCHAR(250) NULL,
			orderType			INT NOT NULL,
			date				DATETIME
									
		)ENGINE=MyISAM DEFAULT CHARSET=utf8");
	}
	
	/*****************************************************/
	$hotels 		= $wpdb->prefix . "hotels";
	if ($wpdb->get_var("SHOW TABLES LIKE '$hotels'") != $hotels)
	{
		$wpdb->query("CREATE TABLE {$hotels}
		(			
			ID  			mediumint(10) AUTO_INCREMENT PRIMARY KEY ,
			hotelID 			INT NOT NULL,			
			typeRoom		 	VARCHAR(50) NOT NULL,			
			max					VARCHAR(50) NOT NULL,
			numberOfroom		INT NULL,
			checkIn				DATETIME,
			checkOUT			DATETIME,
			date				DATETIME
									
		)ENGINE=MyISAM DEFAULT CHARSET=utf8");
	}
	
/*****************************************************/
	$tours		= $wpdb->prefix . "tours";
	if ($wpdb->get_var("SHOW TABLES LIKE '$tours'") != $tours)
	{
		$wpdb->query("CREATE TABLE {$tours}
		(			
			ID  			mediumint(10) AUTO_INCREMENT PRIMARY KEY ,
			tourID 				INT NOT NULL,			
			travelInpartof		VARCHAR(50) NOT NULL,			
			typeTour			VARCHAR(50) NOT NULL,
			proposeDate			DATETIME,			
			date				DATETIME
									
		)ENGINE=MyISAM DEFAULT CHARSET=utf8");
	}
	
	
	/*****************************************************/
	$payments 		= $wpdb->prefix . "payments";
	if ($wpdb->get_var("SHOW TABLES LIKE '$payments'") != $payments)
	{
		$wpdb->query("CREATE TABLE {$payments}
		(			
			ID  			mediumint(10) AUTO_INCREMENT PRIMARY KEY ,
			price				float,
			deposit				float,
			paymentMethod 		VARCHAR(100) NOT NULL,
			paymentCurrent		float,
			paymentDebt			float,
			paymentStatus		VARCHAR(100) NOT NULL,
			date				DATETIME
									
		)ENGINE=MyISAM DEFAULT CHARSET=utf8");
	}
	
	/*****************************************************/
	$destinationFrom 		= $wpdb->prefix . "destination_from";
	if ($wpdb->get_var("SHOW TABLES LIKE '$destinationFrom'") != $destinationFrom)
	{
		$wpdb->query("CREATE TABLE {$destinationFrom}
		(			
			ID  			mediumint(10) AUTO_INCREMENT PRIMARY KEY ,			
			destinationFrom 		VARCHAR(100) NOT NULL												
		)ENGINE=MyISAM DEFAULT CHARSET=utf8");
	}
	
	/*****************************************************/
	$destinationTo 		= $wpdb->prefix . "destination_to";
	if ($wpdb->get_var("SHOW TABLES LIKE '$destinationTo'") != $destinationTo)
	{
		$wpdb->query("CREATE TABLE {$destinationTo}
		(			
			ID  			mediumint(10) AUTO_INCREMENT PRIMARY KEY ,			
			destinationTo 		VARCHAR(100) NOT NULL												
		)ENGINE=MyISAM DEFAULT CHARSET=utf8");
	}	
	
	/*****************************************************/
	$agents 		= $wpdb->prefix . "agents";
	if ($wpdb->get_var("SHOW TABLES LIKE '$agents'") != $agents)
	{
		$wpdb->query("CREATE TABLE {$agents}
		(			
			ID  mediumint(10) AUTO_INCREMENT PRIMARY KEY ,
			companyName 			VARCHAR(150) NOT NULL,
			companyEmail 			VARCHAR(150) NOT NULL,
			companyAddress 			VARCHAR(150) NOT NULL,
			companyPhone 			VARCHAR(150) NOT NULL,
			companyFax 				VARCHAR(150) NOT NULL,
			companyComment			VARCHAR(250) NOT NULL,
			customerID				INT NOT NULL,	
			date		 			DATETIME NOT NULL												
		)ENGINE=MyISAM DEFAULT CHARSET=utf8");
	}
	/*****************************************************/
	$visas 		= $wpdb->prefix . "visas";
	if ($wpdb->get_var("SHOW TABLES LIKE '$visas'") != $visas)
	{
		$wpdb->query("CREATE TABLE {$visas}
		(			
			ID  mediumint(10) AUTO_INCREMENT PRIMARY KEY ,
			numberVisa 			VARCHAR(150) NOT NULL,
			typeVisa 			VARCHAR(150) NOT NULL,
			purposeVisa 		VARCHAR(150) NOT NULL,
			processingTime 		VARCHAR(150) NOT NULL,
			dateArrival 		DATETIME NOT NULL,
			dateExit			DATETIME NOT NULL,
			arrivalAirport		VARCHAR(150) NOT NULL,
			flightNumber		VARCHAR(50) NOT NULL,
			customerID			INT NULL,	
			paymentID			INT NULL,		
			date		 		DATETIME NOT NULL												
		)ENGINE=MyISAM DEFAULT CHARSET=utf8");
	}
	
}